using System.Web.UI;

namespace Synergy.Web.UI.Extensions
{
	/// <summary>
	/// Extension methods for the <see cref="AttributeCollection"/> class.
	/// </summary>
	/// <remarks>
	///		<list type="table">
	///			<listheader><term>Version</term><description>Description</description></listheader>
	///			<item>
	///				<term>1.0</term>
	///				<description>Initial version</description>
	///			</item>
	///		</list>
	/// </remarks>
	public static class AttributeCollectionExtension
	{
		/// <summary>
		/// Adds an <paramref name="attribute"/> to a server control's <paramref name="collection"/>.
		/// </summary>
		/// <param name="collection">The collection.</param>
		/// <param name="attribute">The attribute.</param>
		/// <param name="value">The value.</param>
		public static void Add(this AttributeCollection collection, HtmlTextWriterAttribute attribute, string value)
		{
			// validate params
			if (collection == null)
			{
				return;
			}

			// add attribute value
			collection.Add(attribute.ToString().ToLowerInvariant(), value);
		}
	}
}